var navigation_open = -1;

var navigationArray = new Array();
var navigationDivArray = new Array();
var colorBTstate1 = new Array();
var colorBTstate2 = new Array();

colorBTstate1[0] = "#ec1944";
colorBTstate1[1] = "#47444a";
colorBTstate1[2] = "#47444a";
colorBTstate1[3] = "#47444a";
colorBTstate1[4] = "#47444a";

colorBTstate2[0] = "#f7f7f7";
colorBTstate2[1] = "#ec1944";
colorBTstate2[2] = "#ec1944";
colorBTstate2[3] = "#ec1944";
colorBTstate2[4] = "#ec1944";

navigationArray[0] = "btnav_nav";
navigationArray[1] = "btnav_post";
navigationArray[2] = "btnav_profile";
navigationArray[3] = "btnav_tag";
navigationArray[4] = "btnav_account";

navigationDivArray[0] = 'nav_nav';
navigationDivArray[1] = 'nav_post';
navigationDivArray[2] = 'nav_profile';
navigationDivArray[3] = 'nav_tag';
navigationDivArray[4] = 'nav_account';

function NavOpen(index)
{
	for( var i = 0;i < navigationArray.length;i++)
	{
		if(i != index)
		{
			document.getElementById(navigationArray[i]).style.backgroundColor = colorBTstate1[i];
			document.getElementById(navigationDivArray[i]).style.visibility = "hidden";

		}
		else
		{
			if(index == 0)
			{
				document.getElementById(navigationArray[0]).style.borderColor = "#999999";
			}
			document.getElementById(navigationArray[i]).style.backgroundColor = colorBTstate2[i];
			document.getElementById(navigationDivArray[i]).style.visibility = "visible";
		}
	}
}
function NavClose(index)
{
	if(index == navigation_open)
	{
		navigation_open = -1;

		for( var i = 0;i < navigationArray.length;i++)
		{
			if(i != index)
			{
				document.getElementById(navigationArray[i]).style.backgroundColor = colorBTstate1[i];
				document.getElementById(navigationDivArray[i]).style.visibility = "hidden";
			}
			else
			{
				document.getElementById(navigationArray[i]).style.backgroundColor = colorBTstate2[i];
				document.getElementById(navigationDivArray[i]).style.visibility = "hidden";
			}
		}
		if(index == 0)
		{
			document.getElementById(navigationArray[0]).style.backgroundColor = colorBTstate1[0];
			document.getElementById(navigationArray[0]).style.borderColor = "#ec1944";
		}

	}
	else
	{
		navigation_open = index;
	}
}
function Nav_select(id)
{
	if(detect_browser() != "IE")
	{
		document.getElementById(navigationDivArray[id]).fading(100,0,100);

	}
	NavOpen(id);
	NavClose(id);
}

function detect_browser()
{
	var mybrowser = navigator.userAgent;
	mybs = 'Unknow';
	if(mybrowser.indexOf('MSIE') > 0)
	{
		mybs = "IE";
	}
	if(mybrowser.indexOf('Firefox') > 0)
	{
		mybs = "Firefox";
	}
	if(mybrowser.indexOf('Presto') > 0)
	{
		mybs = "Opera";
	}
	if(mybrowser.indexOf('Chrome') > 0)
	{
		mybs = "Chrome";
	}
	return mybs;
}
